package com.example.rotateimageview.recycleView

import androidx.recyclerview.widget.RecyclerView

/**
 * author  : Liushuai
 * time    : 2021/10/17 14:20
 * desc    :
 */
class CustomLayoutManager : RecyclerView.LayoutManager() {
    override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams {
        return RecyclerView.LayoutParams(
                RecyclerView.LayoutParams.WRAP_CONTENT,
                RecyclerView.LayoutParams.WRAP_CONTENT
        )
    }

    override fun onLayoutChildren(recycler: RecyclerView.Recycler, state: RecyclerView.State?) {
        if (itemCount == 0) {
            //将所有可见的holder剥离
            detachAndScrapAttachedViews(recycler)
            return
        }
        detachAndScrapAttachedViews(recycler)
        val childView=recycler.getViewForPosition(0)
        measureChildWithMargins(childView,0,0)


    }
}